<?php include "include/header.php" ?>
<div class="main-content">
					<div class="container">				
						<div class="page-content">
							<!-- Heading -->
							<div class="single-head">
								<!-- Heading -->
								<h3 class="pull-left"><i class="fa fa-tags green"></i> Report Group</h3>
								<!-- Bread crumbs -->
								<div class="breads pull-right">
									<strong>Nav</strong> : <a href="<?=base_url('/')?>">Home</a> / <a href="<?=base_url('report_group')?>">Report Group</a>
								</div>
								<div class="clearfix"></div>
							</div>
							<!-- Posts page -->
							<div class="page-posts">
								<!-- Nav tabs -->
								<div class="page-tabs">
									<ul class="nav nav-tabs">
										<li class="active"><a href="#posts" class="br-lblue" data-toggle="tab"><i class="fa fa-tags lblue"></i> Report Group</a></li>
										<li><a href="#postnew" class="br-red" data-toggle="tab"><i class="fa fa-tag red"></i> Add Report Group</a></li>
									</ul>
									<!-- Tab panes -->
									<div class="tab-content">
										<div class="tab-pane fade active in" id="posts">
											<div class="table-responsive">
												<form id="report_form">
													<table class="table table-bordered">
														<thead>
															<tr>
																<th><input type="checkbox" name="tablechoice" onclick="var ck = this.checked;$(':checkbox').each(function(){this.checked = ck});"/></th>
																<th>Report name</th>
																<th>Group name</th>
																<th>Group sort</th>
																<th>Edits</th>
															</tr>
														</thead>
														<tbody>														
															<?php foreach ( $groups as $row ) { ?>
																<tr>
																	<td class="gi"><input type="checkbox" name="group_id" value="<?=$row['group_id']?>"/></td>
																	<td class="rn"><?=$row['report_name']?></td>
																	<td class="gn"><?=$row['group_name']?></td>
																	<td class="gs"><?=$row['group_sort']?></td>
																	<td>
																		<a data-toggle="modal" href="#report_group_update" class="btn btn-xs btn-danger report_group_edit"><i class="fa fa-pencil"></i></a>																	
																		<a class="btn btn-xs btn-success report_del" onclick="confirm('Are you sure to delete?',function(flag){if(flag){location.href='<?=base_url('report_group/delete')?>?group_id=<?=$row['group_id']?>'}})" href="javascript:;"><i class="fa fa-trash-o"></i> </a>
																	</td>
																</tr>
															<?php } ?>
														</tbody>
													</table>
												</form>
											</div><!-- Table responsive end -->
											<!--
											<ul class="pagination pull-right">
												<li><a href="#">&laquo;</a></li>
												<li><a href="#">1</a></li>
												<li><a href="#">2</a></li>
												<li><a href="#">3</a></li>
												<li><a href="#">4</a></li>
												<li><a href="#">5</a></li>
												<li><a href="#">&raquo;</a></li>
											</ul>-->
											<div class="clearfix"></div>
										</div>
										<div class="tab-pane fade" id="postnew">
											<!-- Heading -->
											<h4>Add Group</h4>	
											<form class="form-horizontal" role="form" method="post" action="<?=base_url('report_group/add')?>">
												<!-- Report Name area -->
												<div class="form-group">
													<label for="report_name" class="control-label col-md-2">Report Name</label>
													<div class="col-md-10">
														<select id="location" name="report_name" class="form-control">
															<option value="">Select Report Name</option>
															<?php foreach ( $reports as $row ) { ?>
																<option value="<?=$row['report_name']?>"><?=$row['report_name']?></option>
															<?php } ?>
														</select>
													</div>
												</div>
												<!-- group name area -->
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Group Name</label>
													<div class="col-md-10">
														<input type="text" name="group_name" class="form-control" id="title" placeholder="Enter Group Name">
													</div>
												</div>
												<!-- group sort area   -->
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Group Sort</label>
													<div class="col-md-10">
														<input type="text" name="group_sort" class="form-control" id="title" placeholder="Enter Group Sort">
													</div>
												</div>
												
												<!-- Button -->
												<div class="form-group">
													<div class="col-md-offset-2 col-md-10">
														<div class="pull-right">
														<!-- Buttons -->
															<input type="submit" class="btn btn-default" value="Add" />
														</div>
														<div class="clearfix"></div>
													</div>
												</div>
											</form>
										</div>
									</div>
								</div>
							</div> <!-- Posts page end -->
							<!-- report_group update form -->
							<div class="modal fade" id="report_group_update" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
								<div class="modal-dialog">
								    <div class="modal-content">    
					 			        <div class="modal-header">
									        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
										        <h4 class="modal-title" id="exampleModalLabel">Update Report Group</h4>
										</div>
									    <div class="modal-body">
										    <form class="form-horizontal" role="form" method="post" action="<?=base_url('report_group/update')?>">
										    	<input type="checkbox" name="group_id" id="group_id" checked="checked" hidden>
										        <div class="form-group">
													<label for="report_name" class="control-label col-md-2">Report Name</label>
													<div class="col-md-10">
														<select id="report_name" name="report_name" class="form-control">
															<option value="">Select Report Name</option>
															<?php foreach ( $reports as $row ) { ?>
																<option value="<?=$row['report_name']?>"><?=$row['report_name']?></option>
															<?php } ?>
														</select>
													</div>
												</div>
												<div class="form-group">
													<label for="group_name" class="col-lg-2 control-label">Group Name</label>
													<div class="col-lg-10">
														<input type="text" name="group_name" class="form-control" id="group_name">
													</div>
												</div>
												<!-- Post tag area -->
												<div class="form-group">
													<label for="group_sort" class="col-lg-2 control-label">Group Sort</label>
													<div class="col-lg-10">
														<input type="text" name="group_sort" class="form-control" id="group_sort">
													</div>
												</div>
												<button type="submit" class="btn btn-info btn-block">Update</button>
										    </form>
										</div>
										<div class="clearfix"></div>
										<div class="modal-footer"></div>
								    </div>
						        </div>
							</div>
							<!-- report_group update form -->
						</div>
						
					</div>
				
			</div>
			<!-- Mainbar ends -->
			
			<div class="clearfix"></div>
		</div>
<?php include "include/js.php" ?>
<!-- script for this page -->
<script>
$(document).ready(function(){
	
	$("#report_group_update").on('show.bs.modal', function (event) {
		var button = $(event.relatedTarget);
		var group_id = button.parent().prevAll(".gi").children().val();
		var group_name = button.parent().prevAll(".gn").text();
		var report_name = button.parent().prevAll(".rn").text();
		var group_sort = button.parent().prevAll(".gs").text();
		var modal = $(this);
		modal.find('#group_id').val(group_id);
  		modal.find('#report_name').val(report_name);
  		modal.find('#group_name').val(group_name);
  		modal.find('#group_sort').val(group_sort);
	});
});           
</script>
<?php include "include/footer.php" ?>